const app = getApp()
const navs = [
  {
    label: '我要投诉',
    src: 'http://tianyue.1juke.cn/res/Upload/ts.png',
    link: './submit?type=投诉'
  },
  {
    label: '我要建议',
    src: 'http://tianyue.1juke.cn/res/Upload/jy.png',
    link: './submit?type=建议'
  },
  {
    label: '我要表扬',
    src: 'http://tianyue.1juke.cn/res/Upload/by.png',
    link: './submit?type=表扬'
  },
  {
    label: '我的记录',
    src: 'http://tianyue.1juke.cn/res/Upload/jl.png',
    link: '/pages/advise/list?id=1'
  }
]
Page({
  data: {
    navs: []
  },
  onShow() {
    app.memberReadyCb = () => {
      const member = wx.getStorageSync('member')
      let cla = member.Class ? JSON.parse(member.Class) : null
      if (member.Type !== '租户') {
        this.data.navs = navs.slice(2)
      } else {
        if (cla && cla.findIndex(item => item === '管理员') === -1) {
          this.data.navs = navs.slice(1)
        } else {
          this.data.navs = navs
        }
      }
      this.setData({
        member: wx.getStorageSync('member'),
        navs: this.data.navs
      })
    }
    app.fansReadyCb = () => {
      app.checkMember()
    }
    app.init()
  }
})